﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T08string
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = "abc 123 def 456 ghi";
            string[] strArray;

            strArray =str1.Split(' ');
            foreach (var str in strArray)
            {
                Console.WriteLine(str);
            }
            Console.WriteLine("===============================================");

            //规范化
            string username = "aBc";
            Console.WriteLine($"{username.ToLower()}");
            Console.WriteLine($"{username.ToUpper()}");

            Console.WriteLine("===============================================");

            //修改

            string str2 = "xyz 123";
            string str3 = str2.Remove(str2.IndexOf(" "));
            Console.WriteLine($"{str3}");
            Console.WriteLine("===============================================");
            //子串
            string str4 = str2.Substring(str2.IndexOf (" ")).Trim();
            Console.WriteLine($"{str4}");

            Console.WriteLine("=====================================================");

            //比较

            Console.WriteLine($"{str4.CompareTo(username)}");
            Console.WriteLine("=====================================================");

            //查找

            Console.WriteLine($"{str2.Contains("x")}");

            Console.WriteLine("=====================================================");

            //格式化
            string str5 = string.Format("" +
                "{0}年{1}月{2}日",
            DateTime.Today.Year,
            DateTime.Today.Month ,
            DateTime.Today.Day
            );
            Console.WriteLine($"{str5}");

            Console.ReadKey();
        }
    }
}
